<?php
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Traits\HasUuid;

class ApprovalModel extends Model
{
    use HasFactory, HasUuid, SoftDeletes;
    const STATUS_REVOKE = '-1'; //撤回
    const STATUS_APPROVED = '0';  // 审批中
    const STATUS_SUCCESS = '1';  // 审批通过
    const STATUS_FAIL = '2';  // 审批未通过

    public static $statusMap = [
        self::STATUS_APPROVED => '审批中',
        self::STATUS_SUCCESS => '审批通过',
        self::STATUS_FAIL => '审批未通过',
        self::STATUS_REVOKE => '撤回',
    ];

    protected $table = 'approvals';

    protected $fillable = [];

    protected $hidden = ["deleted_at"];

    public function user(): BelongsToMany
    {
        return $this->belongsToMany(UserModel::class, 'approval_flows',
            'approval_id', 'approval_user_id');
    }
}
